package test_ection;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-11-26
 * Time:18:08
 */

public class TestDemo {

}
class myConparator implements Comparator<int[]>{
    @Override
    public  int compare(int[] o1,int[] o2){
        return  o1[0]-o2[0];
    }
}
class Solution {
    public int eraseOverlapIntervals(int[][] intervals) {
        Arrays.sort(intervals,new myConparator());

        int start = intervals[0][0];
        int end = intervals[0][1];
        int num = 0;
        for (int i = 1; i < intervals.length; i++) {
            if (intervals[i][0] > start ){
                start = intervals[i][0];
            }else {
                if (intervals[i][1] < end){
                    start = intervals[i][0];
                    end = intervals[i][1];
                }
                num++;
            }
        }
return num;
    }
}
